<!DOCTYPE HTML>
<html lang="en-US">
<head>
    <meta charset="UTF-8">
    <title></title>
    <script type="text/javascript" src="../../../src/core/_core.js"></script>
    <script type="text/javascript" src="../../../src/core/function.js"></script>
</head>
<body>
<script type="text/javascript">
    var ln2 = {
        bind1:(function () {
            var nativeBind = Function.prototype.bind,
                    slice=Array.prototype.slice;
            return nativeBind ? function (fn, context) {
                return Function.prototype.bind.apply(fn, slice.call(arguments, 1));
            } : function (fn, context) {
                if (arguments.length < 2 && context===undefined) return fn;
                var args = slice.call(arguments, 2);
                return function () {
                    var inArgs = slice.call(arguments, 0);
                    return fn.apply(context, args.concat(inArgs));
                }
            }
        }()),
        bind2:Function.bind || function (fn, context) {
            if (arguments.length < 2 && context===undefined) return fn;
            var args = slice.call(arguments, 2);
            return function () {
                var inArgs = slice.call(arguments, 0);
                return fn.apply(context, args.concat(inArgs));
            }
        }
    };
    //bind
    var obj = {
        VER:0.1,
        getVer:function (prefix) {
            return (prefix || 'ver-') + this.VER;
        }
    };
    function xyz(callback) {
        return callback();
    }
    //var ver=xyz(obj.getVer.call(obj,'afeiVer-'));
    //var ver=xyz(obj.getVer.bind(obj,'afeiVer-'));
    /**
     * Bind方法详解
     */
    var x = 9,
            module = {
                getX:function (y) {
                    return this.x + (y || 1);
                },
                x:81
            };
    //显式作用域
    console.log('01-:', module.getX(2));

    //原生的bind
    var GetX1 = module.getX.bind(module,3);
    console.log('02-:', GetX1());

    //ln2的bind1:
    var GetX2= ln2.bind1(module.getX,module,4);
    console.log('03-:', GetX2());
    //ln2的bind2:
    var GetX3= ln2.bind2(module.getX,module,5);
    console.log('04-:', GetX3());



</script>
</body>
</html>